package proeva;

import java.sql.*;

public class DBSetting
{
	private static String DriverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
	
	private static StringBuffer Eva_Server;
	private static StringBuffer Game_Server;
	private static StringBuffer User;
	private static StringBuffer Password;
	
	public static void setEva_Server(StringBuffer eva_Server) {
		Eva_Server = eva_Server;
	}
	public static StringBuffer getEva_Server() {
		return Eva_Server;
	}
	public static void setGame_Server(StringBuffer game_Server) {
		Game_Server = game_Server;
	}
	public static StringBuffer getGame_Server() {
		return Game_Server;
	}
	public static void setUser( String newUser )
	{
		User = new StringBuffer(newUser);
	}
	public static void setPassword( String Pass)
	{
		Password = new StringBuffer( Pass );
	}
	
	public static String getUser()
	{
		return User.toString();
	}
	
	public static String getPassword()
	{
		return Password.toString();
	}
	
	private static void Init()
	{
		setEva_Server(new StringBuffer("jdbc:sqlserver://localhost:1433;DatabaseName=Evaluation"));
		setGame_Server(new StringBuffer("jdbc:sqlserver://localhost:1433;DatabaseName=Game"));
		User = new StringBuffer("sa");
		Password = new StringBuffer("123456");
	}
	
	public static Connection GetEvaConnection() throws Exception
	{
		Init();
		Class.forName( DriverName );
		try
		{
			Connection Conn = DriverManager.getConnection( getEva_Server().toString() , getUser() , getPassword() );
			return Conn;
		}
		catch( Exception e )
		{
			throw e;
		}
	}
	
	public static Connection GetGameConnection() throws Exception
	{
		Init();
		Class.forName( DriverName );
		try
		{
			Connection Conn = DriverManager.getConnection( getGame_Server().toString() , getUser() , getPassword() );
			return Conn;
		}
		catch( Exception e )
		{
			throw e;
		}
	}
}

